const getFirstDayOfMonth = (date, status = true) => {
  date.setDate(1);
  if (status) return timeFormat(date, status, '月');
  return CurrentMonthLast(date);
}
/* 本月最后一天 */
const CurrentMonthLast = (date) => {
  let currentMonth = date.getMonth();
  let nextMonth = ++currentMonth;
  let nextMonthFirstDay = new Date(date.getFullYear(), nextMonth, 1);
  let oneDay = 1000 * 60 * 60 * 24;
  return timeFormat(new Date(nextMonthFirstDay - oneDay));
}
/* 时间格式处理 */
const timeFormat = (date, status) => {
  const y = date.getFullYear(); //年
  const m = (date.getMonth() + 1).toString().padStart(2, '0'); //月
  const d = date.getDate().toString().padStart(2, '0'); //日
  if (status) return `${y}-${m}-${d} 00:00:00`;
  return `${y}-${m}-${d} 23:59:59`;
}
const getMonthDay = (year, month) => {
  let days = new Date(year, month + 1, 0).getDate()
  return days
}
export {
  getMonthDay,
  getFirstDayOfMonth,
  CurrentMonthLast
}